<%@page import="debug.ConfigDebug"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="models.ConfigModel"%>
<%@page import="models.CategoryModel"%>
<%@page import="java.util.ArrayList"%>
<%
	ArrayList<CategoryModel> categories = (ArrayList<CategoryModel>) request.getAttribute("categories");
	ConfigModel siteConfig = (ConfigModel) request.getAttribute("config");
	String image = UrlHelper.getServerUrl(request) + "/blobstore-serve?blob-key=" + siteConfig.getLogo();
%>
<jsp:include page="/layouts/header.jsp">
    <jsp:param name="title" value="<%=siteConfig.getTitle()%>" />
    <jsp:param name="description" value="<%=siteConfig.getMetaDescription()%>" />
    <jsp:param name="keywords" value="<%=siteConfig.getMetaKeywords()%>" />
    <jsp:param name="ogsite_name" value="<%=siteConfig.getSiteName()%>" />
    <jsp:param name="ogtitle" value="<%=siteConfig.getTitle()%>" />
    <jsp:param name="ogurl" value="<%=UrlHelper.getServerUrl(request)%>" />
    <jsp:param name="ogimage" value="<%=image %>" />
    <jsp:param name="ogdescription" value="<%=siteConfig.getMetaDescription()%>" />
</jsp:include>
		<h2 class="title">Link Directory</h2>
		<br />
		<div class="cats">
			<% 
			int count = 0;
			int num = 0;
			for (int i = 0; i < categories.size(); i++) {
				if (categories.get(i).getLevel() == 1) {
					if (count > 0) {
			%>		
				</h2>
			</div>
			<%
					} 
			%>
			<div class="<%=count%2==0? "lft_cat" : "rgt_cat" %>">
				<h1><a href="/view-category/<%=categories.get(i).getId()%>"><%=categories.get(i).getName() %></a></h1>
				<h2>
			<%  
					count ++;
					num = 0;
				} else {
					num++;
					if (num <= 3) {
			%>
					<a href="/view-category/<%=categories.get(i).getId()%>"><%=categories.get(i).getName() %></a><%=num < 3 ? ", " : "..." %>
			<% 
					}
				 } 
			} %>
				</h2>
			</div>
			<!-- 
			<div class="lft_cat">
				<h1><a href="#">Arts & Humanities</a></h1>
				<h2>
					<a href="#">Photography</a>,
					<a href="#">History</a>,
					<a href="#">Literature</a>...
				</h2>
			</div>
			<div class="rgt_cat">
				<h1><a href="#">Arts & Humanities</a></h1>
				<h2>
					<a href="#">Photography</a>,
					<a href="#">History</a>,
					<a href="#">Literature</a>...
				</h2>
			</div>
			 -->
			<div class="clear"></div>
		</div>
		<br />
<jsp:include page="/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>